﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using LASGui.Classes;
using LASGui.Views;

namespace LASGui
{
    public partial class MainPage : UserControl
    {

        public MainPage()
        {
            
            InitializeComponent();
        }

        /// <summary>
        /// After the Frame navigates, ensure the HyperlinkButton representing the current page is selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentFrameNavigated(object sender, NavigationEventArgs e)
        {
            
            var navigationService = (NavigationService)sender;

            /*foreach (UIElement child in LinksStackPanel.Children)
            {
                var hb = child as HyperlinkButton;
                if (hb != null && hb.NavigateUri != null)
                    VisualStateManager.GoToState(hb, hb.NavigateUri.ToString().Equals(e.Uri.ToString())? "ActiveLink": "InactiveLink", true);
            }*/
        }

        /// <summary>
        /// If an error occurs during navigation, show an error window
        /// </summary>
        /// <param name="sender" />
        /// <param name="e"></param>
        private void ContentFrameNavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            e.Handled = true;
            ChildWindow errorWin = new CustomChildWindow(e.Uri);
            errorWin.Show();
        }
		
		/// <summary>
		/// Muestra el menu para el usuario que ha iniciado sesión
		/// </summary>
        public void ShowMainMenu()
		{
		    LinksBorder.Visibility = Visibility.Visible;
		}

        /// <summary>
        /// Esconde el menu para el usuario que no ha iniciado sesión
        /// </summary>
        public void HideMainMenu()
        {
            LinksBorder.Visibility = Visibility.Collapsed;
        }
    }
}